<script>
import { fetch } from './utils/fetch'
export default {
  onLaunch: function () {
    console.warn('当前组件仅支持 uni_modules 目录结构 ，请升级 HBuilderX 到 3.1.0 版本以上！')
    console.log('App Launch')
    if (uni.getStorageSync('token')) {
      // const token = uni.getStorageSync('token')
      // console.log('token', token)
    } else {
      wx.login({
        success: async res => {
          console.log('res:', res.code)
          const response = await fetch({
            url: 'http://localhost:3000/api/login',
            method: 'POST',
            data: { code: res.code }
          })
          uni.setStorageSync('token', response.data.data.token)
          console.log('response:', response.data.data.token)
        }
      })
    }
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  }
}
</script>

<style lang="scss">
/*每个页面公共css */
@import '@/uni_modules/uni-scss/index.scss';
/* #ifndef APP-NVUE */
@import '@/static/customicons.css';
// 设置整个项目的背景色
page {
  background-color: #f5f5f5;
}

/* #endif */
.example-info {
  font-size: 14px;
  color: #333;
  padding: 10px;
}
</style>
